/**
 * @author rxliuli
 */
const app = new BasicTableVue({
    el: '#app',
    data() {
        return {
            api: moIllegalInfoApi,
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                new TableColumn({prop: 'houseId', title: '所在机房'}),
                new TableColumn({prop: 'ip', title: '应用 IP'}),
                new TableColumn({prop: 'accessDomain', title: '访问域名'}),
                new TableColumn({prop: 'accessUrlCount', title: '网址个数'}),
                new TableColumn({
                    prop: 'dealStatus',
                    title: '处置状态',
                    formatter: fieldFormatter.facade(fieldFormatter.moFilingSupervise.dealStatusMap),
                }),
                new TableColumn({prop: 'fstFoundTime', title: '首次发现时间', formatter: TableColumn.datetimeFormat}),
                new TableColumn({prop: 'lastFoundTime', title: '最近发现时间', formatter: TableColumn.datetimeFormat}),
            ],
            excludeFieldSet: new Set(['firstFoundTimeRange', 'lastFoundTimeRange', 'dealTimeRange']),
            sysUserMap: new Map(),
            houseMap: new Map(),
        }
    },
    methods: {
        createForm() {
            return new MoIllegalInfo({
                dangerLevel: undefined,
                lastFoundTime: this.dateNow,
                firstFoundTimeRange: [],
                lastFoundTimeRange: [],
                dealTimeRange: [],
                dangerFactorAction: undefined,
            })
        },
        async getPage(page,entity) {
            return this.api.pageCount(page, rx.excludeFields(this.form, ...Array.from(this.excludeFieldSet)))
        },
        async init() {
            this.sysUserMap = rx.arrayToMap(await sysUserApi.selectList(), ({id}) => id, ({loginName}) => loginName)
            this.houseMap = rx.arrayToMap(await baseHouseInfoApi.selectList(), ({id}) => id, ({houseName}) => houseName)
        },
    },
    computed: {
        dateNow() {
            return rx.dateFormat(new Date(), 'yyyy-MM-dd')
        },
        fieldFormatter() {
            return fieldFormatter
        },
    },
})